<template>
  <el-table :data="tableData" class="w-full" stripe>
    <el-table-column label="项目名称">
      <template #default="{ row }">
        <el-link type="primary" @click="handleShow(row.projectId)">{{ row.projectName }}</el-link>
      </template>
    </el-table-column>
    <el-table-column prop="chargerName" label="负责人" />
    <el-table-column label="项目分类">
      <template #default="{ row }">
        <CommonTreeLabel :dataList="projectTypeList" :value="row.projectTypeCode" />
      </template>
    </el-table-column>
    <el-table-column prop="lixiangDate" label="立项日期" />
    <el-table-column label="所属单位">
      <template #default="{ row }">
        <CommonTreeLabel
          :dataList="unitList"
          valueKey="codeColumn"
          labelKey="valueColumn"
          :value="row.unitId"
        />
      </template>
    </el-table-column>
    <el-table-column prop="fee" label="批准经费（万元）" />
    <el-table-column label="审核状态">
      <template #default="{ row }">
        <CommonLabel
          :dataList="checkStatusList"
          valueKey="dictValue"
          labelKey="dictLabel"
          :value="row.checkStatus"
        />
      </template>
    </el-table-column>
  </el-table>
  <ViewProject ref="viewProjectRef" />
</template>

<script setup>
import CommonTreeLabel from "@/views/project/components/CommonTreeLabel.vue";
import CommonLabel from "@/views/project/components/CommonLabel.vue";
import ViewProject from "@/views/project/components/ViewProject";
import { historyJoinProject } from "@/api/project/xj/sbxm";
import useCommonFetch from "@/hooks/useCommonFetch";
import useDictFetch from "@/hooks/useDictFetch";
const projectTypeList = useCommonFetch("项目分类（校级）");
const unitList = useCommonFetch("成果归属单位");
const checkStatusList = useDictFetch("bpm_process_instance_status"); //审核状态
const viewProjectRef = ref();
const props = defineProps({
  applierId: String,
});
const tableData = ref([]);
//获取数据
const getTableData = async () => {
  const params = {
    applierId: props.applierId,
  };
  try {
    const res = await historyJoinProject(params);
    if (res.code == 200) {
      tableData.value = res.rows;
    }
  } catch (error) {
    console.log(error);
  }
};
//点击名称查看项目信息
const handleShow = (id) => {
  viewProjectRef.value.view(id, "xJProject");
};
onMounted(() => {
  getTableData();
});
</script>

<style scoped lang="scss"></style>
